package uml.view;

import java.awt.BorderLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JPanel;
import javax.swing.JTextArea;

import uml.util.listeners.DragListener;
import uml.util.listeners.Dragable;

/**
 * The super class for all UMLContainerView objects.
 * 
 * @author Evan Curtis and Neil Obetz
 *
 */

public class UMLContainerView
		extends JPanel
		implements Dragable
{


	/**
	 * 
	 */
	private static final long serialVersionUID = 9214675205263893993L;

	/**
	 * Creates a default UMLContainerView.
	 */
	
	public UMLContainerView ()
	{
		setLayout (new BorderLayout ());
	}

	/**
	 * Gives subclasses a way to correctly handle the addition of DragListeners without 
	 * having to worry about the details of mouse interfaces.
	 * 
	 * @param listener The DragListener to be added.
	 */
	
	public void addDragListener (DragListener listener)
	{
		addMouseListener (listener);
		addMouseMotionListener (listener);
	}

	/**
	 * Allows subclasses to add a specified number of JTextAreas. Subclasses should override this 
	 * method to provide a more appropriate functionality.
	 * 
	 * @param numberOfFields The number of fields to add to this object.
	 */
	
	public void addFields (int numberOfFields)
	{
		JTextArea textArea;
		for (int i = 0; i < numberOfFields; ++i)
		{
			textArea = new JTextArea ("Default Text");
			textArea.getBackground ();
			add (textArea);
		}
	}
}
